package com.cyl.manager.pms.controller;


import com.cyl.h5.domain.query.Pageable;
import com.cyl.manager.pms.domain.entity.IndexBanner;
import com.cyl.manager.pms.service.IndexBannerService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 首页轮播图Controller
 *
 * @author zcc
 * @date 2025-02-08
 */
@Api(description ="首页轮播图接口列表")
@RestController
@RequestMapping("/indexBanner/pmsIndexBanner")
public class IndexBannerController extends BaseController {
    @Autowired
    private IndexBannerService service;

    @ApiOperation("查询首页轮播图列表")
    @PreAuthorize("@ss.hasPermi('indexBanner:pmsIndexBanner:list')")
    @PostMapping("/list")
    public TableDataInfo list( Pageable page) {
        List<IndexBanner> list = service.selectList(page);
        TableDataInfo dataTable = getDataTable(list);
        return dataTable;
    }

//    @ApiOperation("获取首页轮播图详细信息")
//    @PreAuthorize("@ss.hasPermi('indexBanner:pmsIndexBanner:query')")
//    @GetMapping(value = "/{id}")
//    public ResponseEntity<PmsIndexBanner> getInfo(@PathVariable("id") Integer id) {
//        return ResponseEntity.ok(service.selectById(id));
//    }

    @ApiOperation("新增首页轮播图")
    @PreAuthorize("@ss.hasPermi('indexBanner:pmsIndexBanner:add')")
//    @Log(title = "首页轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody IndexBanner pmsIndexBanner) {
        return ResponseEntity.ok(service.insert(pmsIndexBanner));
    }

    @ApiOperation("删除首页轮播图")
    @PreAuthorize("@ss.hasPermi('indexBanner:pmsIndexBanner:remove')")
//    @Log(title = "首页轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
